<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>智能创作平台</title>

  <link rel="icon" href="image/til.png" type="image/x-icon">
  <link rel="stylesheet" href="css/index.css">
  <link rel="stylesheet" href="css/all_header.css">
  <script src="js/time.js"></script>
  <script src="js/reconnecting-websocket.js" ></script>
  <script src="js/jquery.js"></script>
  <script src="js/websocket.js"></script>
  <!--google fonts-->
  <link href="css/css2" rel="stylesheet">
  <!-- Boxicons -->
  <link href="css/boxicons.min.css" rel="stylesheet">
  <!-- insha style css-->
  <link rel="stylesheet" href="css/insha-style.css">
  <link rel="stylesheet" href="css/platform.css">
</head>


<body>
<!-- main wrapper -->
<div class="main">
  <div class="sidebar">
    <div class="logo_content">
      <div class="logo">
        <div class="logo_name">
          <a href="">
            <i class="bx bx-meteor"></i>
            智能创作平台
          </a>
        </div>
      </div>
      <i class="bx bx-menu" id="toggle-menu-btn"></i>
    </div>
    <ul class="nav_list">
      <li>
        <i class="bx bx-search search-btn" id="search"></i>
        <input type="text" id="key" placeholder="搜索...">
        <span class="tooltip">搜索</span>
      </li>
      <li>
        <a href="/platform">
          <i class="bx bx-grid-alt"></i>
          <span class="links_name">创作中心</span>
        </a>
        <span class="tooltip">创作中心</span>
      </li>
      <li>
        <a href="/userInfo">
          <i class="bx bx-user"></i>
          <span class="links_name">用户信息</span>
        </a>
        <span class="tooltip">用户信息</span>
      </li>
      <li>
        <a href="/history">
          <i class="bx bx-history"></i>
          <span class="links_name">创作历史</span>
        </a>
        <span class="tooltip">创作历史</span>
      </li>
      <li>
        <a href="/trash">
          <i class="bx bx-recycle"></i>
          <span class="links_name">回收站</span>
        </a>
        <span class="tooltip">回收站</span>
      </li>
      <li>
        <a href="/help">
          <i class="bx bx-help-circle"></i>
          <span class="links_name">帮助文档</span>
        </a>
        <span class="tooltip">帮助文档</span>
      </li>


    </ul>
    <div class="profile_content">
      <div class="profile">
        <div class="profile_details">
          <img src="images/logo.jpg" alt="profile">
          <div class="name_job">
            <div class="name">版权所有</div>
            <div class="job">中国矿业大学</div>
          </div>
        </div>
        <i class="bx bx-log-out" id="log_out" onclick="userExit()" style="cursor: pointer"></i>
      </div>
    </div>
  </div>

  <script>
    function userExit(){
      var exitOrNot = confirm("确认退出吗，账号将注销");
      if (exitOrNot === true){
        window.location.href="/exit";
      } else  {
      }
    }
  </script>

  <div class="home_content" style="overflow: auto">
    <div class="all_header">
      <div class="top_container">
        <div class="page_title">创作中心</div>
        <div class="ts">
          <span class="hello">尊敬的</span>
          <span class="hello" th:text="${session.user.name}" onclick="window.location.href='/userInfo'" style="cursor: pointer"></span>
          <span class="hello">，现在是</span>
          <span class="date"></span>
          <span class="second"></span>
        </div>
      </div>
    </div>
    <div class="text"><br /><textarea placeholder="请输入文本..." class="input-box" id="input-box" type="text"></textarea>
      <div style="margin-top: 0.6vh;margin-bottom: 0.6vh">
        <button class="submit" id="send" onclick="sendMessage()">文章提取</button>
        <button class="submit" id="save" >保存</button><!--onclick="sendMessage()"-->
        <button class="submit" id="readFile">读取文件</button>
        <input class="submit" type="file" style="display:none" id="file">
      </div>
      <script>
        var btn_read = document.querySelector('#readFile');
        var input = document.querySelector('#file');
        var area = document.querySelector("#input-box");
        btn_read.addEventListener('click', ()=>{
          input.click();
        });
        input.addEventListener('change', function() {
          if(this.files.length){
            let file = this.files[0];
            let reader = new FileReader();
            reader.onload = function(){
              text = this.result + "\r\n";
              area.value = this.result + "\r\n";
            };
            reader.readAsText(file);
          }
        }, false);
      </script>

      <script src="js/index.js"></script>
      <a href="http://www.bootstrapmb.com" style="display:none">bootstrapmb</a>
      <textarea placeholder="摘要" id="summary-box" style="resize:none;" ></textarea><!--readonly-->
      <textarea placeholder="标题" id="title-box" style="resize:none;" ></textarea><!--readonly-->
    </div>
  </div>
</div>
<script>
  $("#save").on("click", function () {
    console.log($("#input-box").val());
    console.log($("#summary-box").val());
    console.log($("#title-box").val());
    $.ajax({
      url:"/platform/save",
      type:"GET",
      data:{
        originText: $("#input-box").val(),
        summary: $("#summary-box").val(),
        title: $("#title-box").val()
      },
      resultType:"JSON",
      success:function (result){
        // console.log(result.message);
        // console.log(result.originText);
        if (result.code == 200) {
          alert(result.message);
        }
      },
      error:function (result){
        alert(result.message);
      }
    });
  });
</script>
<!--custom js-->
<script src="js/sidebar.js"></script>
</body>
</html>